package cn.edu.lcu.cs.designpattern.composite.safety;

public class Leaf extends Node {
    public Leaf(String value) {
        setValue(value);
        setType(NODE_TYPE_LEAF);
    }

    public Leaf() {
        setType(NODE_TYPE_LEAF);
    }

    @Override
    public void print() {
        System.out.println("叶子结点【" + getValue() + "】");
    }

    @Override
    public void traversal() {
        this.print(); // 叶子节点，只打印自己的值。
    }
}
